package com.yuandian.bpm.bi.modules.customs.controller;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.yuandian.bpm.bi.modules.customs.sevice.CustomReportService;
import com.yuandian.bpm.common.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/customExport")
public class CustomController {


	@Autowired
	private CustomReportService customReportService;

	/**
	 * 报表参数查询
	 * @param reportId 报表id
	 * @return 通用返回对象
	 */
	@PostMapping("/exportAllExcelStream")
	public R exportAllExcelStream( @RequestBody JSONObject jsonObject) {
		String excelConfigId = jsonObject.getString("excelConfigId");
		if(ObjectUtil.isEmpty(excelConfigId)){
			throw new RuntimeException("报表id不能为空");
		}
		customReportService.exportAllExcelStream(jsonObject);
		return R.ok();

	}
	/**
	 * 查询报表模板
	 * @param reportId 报表id
	 * @return 通用返回对象
	 */
	@GetMapping("/excelQuery")
	public R excelQuery(String reportType, String name, Integer pageNo, Integer pageSize) {

		return R.ok(customReportService.excelQuery(reportType, name));

	}


}
